/// @tags: BinarySearch
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int const N = 2e5 + 5;

struct Node {
  int p, c;
  Node(int p = 0, int c = 0) : p(p), c(c) {}
} sta[N];

int n, top;
int a[N];

void insert(int p, int x) {
  while (sta[top].p > p) --top;
  sta[top].p == p ? sta[top].c++ : sta[++top] = Node(p, 1);
  if (top > 1 && sta[top].c == x) top--, insert(p - 1, x);
}

inline int check(int x) {
  sta[top = 1] = Node(0, 0);
  for (int i = 2; i <= n; ++i)
    if (a[i] <= a[i - 1]) insert(a[i], x);
  return sta[1].c == 0;
}

inline int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int cnt = 0;
  for (int i = 2; i <= n; i++) cnt += a[i] > a[i - 1];
  if (cnt == n - 1) return puts("1"), 0;
  int l = 2, r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    check(mid) ? r = mid : l = mid + 1;
  }
  cout << l;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("AT4502 [AGC029C] Lexicographic constraints.in", "r", stdin);
  freopen("AT4502 [AGC029C] Lexicographic constraints.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
